package com.example.shiwuyouproject.ui.fragment.home.adapter

import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.shiwuyouproject.R
import com.example.shiwuyouproject.ui.fragment.home.bean.HomeRecommendListDataBean
import com.example.shiwuyouproject.utils.DisplayUtil
import com.example.shiwuyouproject.utils.GlideUtils
import com.example.shiwuyouproject.utils.TimeUtils

class homeAdapter() :
    BaseQuickAdapter<HomeRecommendListDataBean?, BaseViewHolder?>(R.layout.item_home) {

    override fun convert(helper: BaseViewHolder?, item: HomeRecommendListDataBean?) {
        if (data.size == helper?.adapterPosition) {
            helper.getView<ConstraintLayout>(R.id.homeItem)
                .setPadding(0, 0, 0, DisplayUtil.dip2px(mContext, 20f))
        }
        helper?.setText(R.id.tvTitle, item?.title)
            ?.setText(R.id.tvOrgName, item?.org_name)
            ?.setText(R.id.tvAddress, item?.show_address)
            ?.setText(
                R.id.tvWorkDay, item?.getWorkDayTitle() + " "
                        + TimeUtils.HourMM(item?.start_time) + "-"
                        + TimeUtils.HourMM(item?.end_time)
            )
            ?.setText(R.id.tvapplyTime, "学生：" + item?.stu_num + "人")
        if (item?.status == "-1") {
            helper?.setText(R.id.tvTypeMoney, "停止招聘")
            helper?.getView<TextView>(R.id.tvTypeMoney)?.isSelected = false
        } else {
            helper?.setText(R.id.tvTypeMoney, item?.fee_start_show+"~"+item?.fee_end_show + "元/小时")
            helper?.getView<TextView>(R.id.tvTypeMoney)?.isSelected = true
        }
        GlideUtils.fangImgPortrait(mContext, helper?.getView(R.id.haderImg)!!, item?.avatar!!)
    }
}